package it.unibo.deis.lia.mmhc.spm;

import java.io.Serializable;
import java.util.Vector;

public class ServicePacket implements Serializable {

	private String name;
	private int port;
	private String fornitore;
	private String richiedente;
	private Vector<String> goHops;
	private Vector<String> backHops;
	private int numberBackHop;
	private int numberGoHop;
	private boolean isGo;
	private Object obj;

	public ServicePacket(String name, int port, String fornitore,
			String richiedente, Vector<String> goHops, Vector<String> backHops,
			Object obj) {
		super();
		this.name = name;
		this.port = port;
		this.fornitore = fornitore;
		this.richiedente = richiedente;
		this.goHops = goHops;
		this.backHops = backHops;
		this.numberBackHop = 0;
		this.numberGoHop = 0;
		this.isGo = true;
		this.obj = obj;
	}

	public boolean isGo() {
		return isGo;
	}

	public void setGo(boolean isGo) {
		this.isGo = isGo;
	}

	public String getName() {
		return name;
	}

	public int getPort() {
		return port;
	}

	public String getFornitore() {
		return fornitore;
	}

	public String getRichiedente() {
		return richiedente;
	}

	public Vector<String> getGoHops() {
		return goHops;
	}

	public Vector<String> getBackHops() {
		return backHops;
	}

	public int getNumberBackHop() {
		return numberBackHop;
	}

	public int getNumberGoHop() {
		return numberGoHop;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public String nextHop() {
		String hop;
		if (isGo) {
			hop = goHops.elementAt(numberGoHop);
			numberGoHop++;
			return hop;
		} else if (!isGo) {
			hop = backHops.elementAt(numberBackHop);
			numberBackHop++;
			return hop;
		} else
			return null;

	}

}
